package com.mycompany.entity;

import com.mycompany.utils.PomodoroState;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

@Entity
public class Pomodoro implements Serializable {
    @Transient
    public static final int duration = 25; //En minutos
    @Transient
    public static final int shortRestDuration = 5; //En minutos
    @Transient
    public static final int longRestDuration = 15; //En minutos
    @Transient
    public static final int numberOfPomodorosPerCicle = 4;
    
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @Column(nullable=false)
    @Enumerated(EnumType.STRING)            
    private PomodoroState pomodoroState;
    @Temporal(TemporalType.TIMESTAMP)    
    private Date startedTime;
    @Temporal(TemporalType.TIMESTAMP)
    private Date finishedTime;
    private String notes;
    @ManyToOne
    private PomodoroUser user;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
    
    public PomodoroState getPomodoroState() {
        return pomodoroState;
    }

    public void setPomodoroState(PomodoroState pomodoroState) {
        this.pomodoroState = pomodoroState;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Pomodoro)) {
            return false;
        }
        Pomodoro other = (Pomodoro) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.mycompany.entity.Pomodoro[ id=" + id + " ]";
    }

    /**
     * @return the startedTime
     */
    public Date getStartedTime() {
        return startedTime;
    }
    
    public void setStartedTime(Date startedTime) {
        this.startedTime = startedTime;
    }

    /**
     * @return the finishedTime
     */
    public Date getFinishedTime() {
        return finishedTime;
    }

    /**
     * @param finishedTime the finishedTime to set
     */
    public void setFinishedTime(Date finishedTime) {
        this.finishedTime = finishedTime;
    }

    /**
     * @return the notes
     */
    public String getNotes() {
        return notes;
    }
    
    public void setNotes(String notes) {
        this.notes = notes;
    }

    /**
     * @return the user
     */
    public PomodoroUser getUser() {
        return user;
    }

    /**
     * @param user the user to set
     */
    public void setUser(PomodoroUser user) {
        this.user = user;
    }
    
}
